#pragma once 
#include <iostream>
#include <string>

std::string opers = "+-*/%";

enum{
    DivZero=1,
    ModZero,
    Unkown
};

class Task
{
public:
    Task() {}
    Task(int x, int y, char op): _data1(x), _data2(y), _oper(op)
    {}
    void run()
    {
        switch (_oper)
        {
            case '+':
                _result = _data1 + _data2; break;
            case '-':
                _result = _data1 - _data2; break;
            case '*':
                _result = _data1 * _data2; break;
            case '/': 
                {
                    if (_data2 == 0) _exitcode = DivZero;
                    else _result = _data1 / _data2;
                }
                break;
            case '%':
                {
                    if (_data2 == 0) _exitcode = ModZero;
                    else _result = _data1 % _data2;
                }
                break;
            default: 
                _exitcode = Unkown; break;
        }
    }
    void operator()()
    {
        run();
    }
    std::string GetResult()
    {
        std::string result = std::to_string(_data1);
        result += _oper;
        result += std::to_string(_data2);
        result += " = ";
        result += std::to_string(_result);
        result += " [code: " + std::to_string(_exitcode) + "]";
        return result;
    }
    std::string GetTask()
    {
        std::string task = std::to_string(_data1);
        task += _oper;
        task += std::to_string(_data2);
        task += " = ?";
        return task;
    }
    ~Task()
    {}
private:
    int _data1;
    int _data2;
    char _oper;

    int _result = 0;
    int _exitcode = 0;
};